Testing Basics (Important Things, Mostly Forgotten)

This is where pathology lives. This sort of thinking is fundamental to every test that we perform, every diagnosis that we render. A few sticking points that I (and most people) struggle with:

  1. Prevalence of disease determines context.
  2. A certain irony is detected in sensitivity and specificity:

The essentials of sensitivity and specificity are made memorable by SPIN (specific to rule in) and SNOUT (sensitive to rule out).

Test Result Disease No Disease Totals
Positive A B A + B
Negative C D C + D
Totals A + C B + D A + B + C + D

\[Accuracy = (A+B)/(A+B+C+D)\] \[Sensitivity=A/(A+C)\] \[Specificity=D/(B+D)\] \[Positive Predictive Value=A/(A+B)\] \[Negative Predictive Value=D/(C+D)\]

Let’s see, for instance, how prevalence affects the behavior of a test. Make the following assumptions: Prevalence=0.01 (1%) Sensitivity of our test=90% Specificity of our test=90% We have 1000 patients to examine.

Test Result Disease No Disease Totals
Positive 9 99 108
Negative 1 891 892
Totals 10 990 1000

\(Positive Predictive Value = A/(A+B) = 9/108 = 8.3\)%

\(Negative Predictive Value = D/(C+D) = 891/892 = 99\)%

Now, when prevalence changes, our PPV and NPV also change: Prevalence=0.1 (10%) Sensitivity of our test=90% Specificity of our test=90% We have 1000 patients to examine.

Test Result Disease No Disease Totals
Positive 90 90 180
Negative 10 810 820
Totals 100 900 1000

\(Positive Predictive Value=A/(A+B)=90/180=50\)%

\(Negative Predictive Value=D/(C+D)=810/820=99\)%

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00
summary(iris)
##   Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
##  Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100  
##  1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300  
##  Median :5.800   Median :3.000   Median :4.350   Median :1.300  
##  Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199  
##  3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800  
##  Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500  
##        Species  
##  setosa    :50  
##  versicolor:50  
##  virginica :50  
##                 
##                 
## 

Spiffy Plot

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Make sure to comment out your code, but what role comments in RMD documents?

Hey, should I write the GATA3 paper in RMD? Small changes are not worth committing, since a committed document is the “gold standard,” the “display copy,” if you like. Nonetheless, the habit of committing is important.

Why use the git interface in RStudio rather than the terminal in RStudio? Doesn’t seem to add much, and it keeps me slightly further from git…

How do references work in Rmd? Here’s a reference dropped in with citr(1,2). I finally got citr installed when I realized that my R version was not the latest, and was preventing the loading of some dependent packages. Dumb, I know.

YAML specifications including output, bibliography, and CSL are important for inserting citations.

library(tidyverse)
ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy, color = class))

Why not make this into a page that contains useful things, like math? I should learn some LATEX(?), anyway.

Images can also be inserted as below.

Images will build up, so are placed in a folder that I set up in the Rproj folder.

References:

1. D&D basic rules: Dungeon master’s basic rules version 0.5. 2018.

2. D&D basic rules: Player’s basic rules version 0.3. 2018.